/*
*	Created:			06.03.10
*	Author:				009
*	Last Modifed:		-
*/

// plugin
#include "os.h"
#include "SyncStructs.h"
// core
#include <stdio.h>

class CNPC
{
public:
	CNPC(int npcid,char* npcname);
	~CNPC();

	void	ResetStat();
	bool	IsActive();
	// states
	void	Spawn();
	void	Kill(int killerid,int reason);
	// player
	// pos
	void	SetPos(float x,float y,float z);
	void	GetPos(float* x,float* y,float* z);
	// quat
	void	SetQuaternion(float x,float y,float z,float s);
	void	GetQuaternion(float* x,float* y,float* z,float* s);
	// angle
	void	SetAngle(float angle);
	float	GetAngle();
	// velocity
	void	SetVelocity(float x,float y,float z);
	void	GetVelocity(float* x,float* y,float* z);
	// camera pos
	void	SetCameraPos(float x,float y,float z);
	void	GetCameraPos(float* x,float* y,float* z);
	// camera front vector
	void	SetCameraFrontVector(float x,float y,float z);
	void	GetCameraFrontVector(float* x,float* y,float* z);
	// camera z aim
	void	SetCameraZAim(float angle);
	float	GetCameraZAim();
	// camera mode
	void	SetCameraMode(int mode);
	int		GetCameraMode();
	// weapon state
	void	SetWeaponState(int wstate);
	int		GetWeaponState();
	// keys
	void	SetKeys(int ud,int lr,int other);
	void	GetKeys(int* ud,int* lr,int* other);
	// state
	void	SetState(int newstate);
	int		GetState();
	// special action
	void	SetSpecialAction(int actionid);
	int		GetSpecialAction();
	// weapon
	void	SetWeapon(int weaponid);
	int		GetWeapon();
	// weapon skill
	void	SetWeaponSkillLevel(int weapontype,int level);
	int		GetWeaponSkillLevel(int weapontype);
	// health
	void	SetHealth(float health);
	float	GetHealth();
	// armour
	void	SetArmour(float armour);
	float	GetArmour();
	// interior
	void	SetInterior(int interior);
	int		GetInterior();
	// skin
	void	SetSkin(int skin);
	int		GetSkin();
	// surfing
	void	SetSurfing(float x,float y,float z);
	void	GetSurfing(float* x,float* y,float* z);
	// surfing vehicle
	void	SetSurfingVehicle(int vehicleid);
	int		GetSurfingVehicle();
	//
	// vehicle
	// state
	void	PutInVehicle(int vehicleid,int seat);
	// pos
	void	SetVehiclePos(float x,float y,float z);
	void	GetVehiclePos(float* x,float* y,float* z);
	// quat
	void	SetVehicleQuaternion(float x,float y,float z,float s);
	void	GetVehicleQuaternion(float* x,float* y,float* z,float* s);
	// direction
	void	SetVehicleVelocity(float x,float y,float z);
	void	GetVehicleVelocity(float* x,float* y,float* z);
	// keys
	void	SetVehicleKeys(int ud,int lr,int other);
	void	GetVehicleKeys(int* ud,int* lr,int* other);
	// siren
	void	SetVehicleSiren(int state);
	int		GetVehicleSiren();
	// health
	void	SetVehicleHealth(float health);
	float	GetVehicleHealth();
	// unique
	void	SetVehicleUnique(float unique);
	float	GetVehicleUnique();
	// weapon
	void	SetVehicleWeapon(int weaponid);
	int		GetVehicleWeapon();
	// trailer
	void	SetVehicleTrailer(int trailer);
	int		GetVehicleTrailer();
	//
	// passanger
	void	SetPassangerDriveBy(int dstate);
	int		GetPassangerDriveBy();
	// keys
	void	SetPassangerKeys(int ud,int lr,int other);
	void	GetPassangerKeys(int* ud,int* lr,int* other);
	// weapon
	void	SetPassangerWeapon(int weaponid);
	int		GetPassangerWeapon();
	//
	// all
	void	SetImpregnable(bool istate);
	bool	IsImpregnable();
	// moving
	void	GoTo(float x,float y,float z,float step,int use_z_map);
	void	DriveTo(float x,float y,float z,float step,int use_z_map);
	void	Stop();
	//
	// playbacks
	int		StartRecordingPlayback(char* name);
	void	ReadNextPlaybackBlock();
	void	PauseRecordingPlayback();
	void	ContinueRecordingPlayback();
	void	StopRecordingPlayback(int reason);
	//
	// thread
	void	Sync();
	int		WeaponDamage(int a_id,float cp_x,float cp_y,float cp_z,float f_x,float f_y,float f_z,float health,int weapon,int type);
	int		VehicleDamage(int a_id,float cp_x,float cp_y,float cp_z,float f_x,float f_y,float f_z,float health,int weapon,int type);
	void	VehicleKnock(int a_id,float pos_x,float pos_y,float pos_z,float v_x,float v_y,float v_z);
	//

	DWORD	c_player_struct;
	int		state;

	float	g_len;
	float	vX;
	float	vY;
	float	vZ;
	float	speed;
	bool	IsMoving;
	bool	IsUseZMap;
	// playbacks
	bool		IsPlayback;
	int			PlaybackType;
	FILE*		PlaybackFile;
	int			StartTime;
	InCarSync	CurrentBlockInCarData;
	OnFootSync	CurrentBlockOnFootData;
	long		CurrentBlockTime;
	// check fire
	float	tmp_x;
	float	tmp_y;
	float	tmp_z;
	float	np_x;
	float	np_y;
	float	np_z;
	float	d_len;
	int		part;
	// check knock
	float	fly_x;
	float	fly_y;
	float	fly_z;

private:
	bool	status;
	int		myid;
	bool	impregnable;
};
